﻿using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for ProRegister
/// </summary>
public class ProRegister
{
    public ProRegister()
    {
        //
        // TODO: Add constructor logic here
        //
    }

    //false : can't insert or insert error.
    //true: Insert successful
    public Boolean InsertAccount(UserInfo ui)
    {
        Boolean bResult = false;
        ConnectDB db = new ConnectDB();
        bResult = db.addUser(ui);

        return bResult;
    }

    //false: don't exist
    //true: exist
    public Boolean CheckUserExist(String strUserName)
    {
        ConnectDB db = new ConnectDB();
        DataSet ds = new DataSet();
        ds = db.isExistUser(strUserName);

        if (ds == null || ds.Tables[0].Rows.Count == 0)
            return false;
        else
            return true;
    }

    public DataSet LoadDepartment()
    {
        ConnectDB db = new ConnectDB();
        DataSet ds = new DataSet();
        ds = db.getListDepartment();
        return ds;
    }

    public DataSet LoadPosition()
    {
        ConnectDB db = new ConnectDB();
        DataSet ds = new DataSet();
        ds = db.getListPosition();
        return ds;
    }

    public DataSet LoadUser(string user)
    {
        ConnectDB db = new ConnectDB();
        DataSet ds = new DataSet();
        ds = db.isExistUser(user);
        return ds;
    }



}
